Release 10.1A: OpenEdge Development:
Progress Dynamics Basic Development
Calculated field support
Dynamic SmartDataObjects (and dynamic viewers) support calculated fields. When you add a calculated field to a dynamic SDO with the Calculated Field button, you can set the following attributes with the column editor:
Note: AName,Label,DataType,Format, andHelp.CalculatedFieldclass extends theDataFieldclass to support placement of calculated fields onto dynamic SDOs and dynamic viewers. This class should not be used and is not supported for any purpose other than calculated fields. Dynamic SDOs support calculated fields by invoking a function that follows a specific naming convention to calculate the values.The
Nameattribute must be the same as thecalculatedFieldobject filename. You cannot specify an expression for the calculated field; therefore the framework disables the Edit button. You must write code to calculate the value for the field in a function of the dynamic SDO's data logic procedure and then name the function according to the required naming convention. The dynamic SDO invokes the function at run time to get the calculated value into its temp-table.The framework creates a master
calculatedFieldobject in the Repository for each calculated field added to a dynamic SDO. If a mastercalculatedFieldalready exists in the Repository, the framework raises an error and you must change the name of that calculated field in the SDO. ThecalculatedFieldmaster object has the same product module as the SDO. Master calculated fields cannot be reused on dynamic SDOs. You can create acalculatedFieldinstance object for the dynamic SDO in the same way as you create aDataFieldinstance object.Calculated field functions
Dynamic SDO calculated fields must have functions defined in the SDO’s logic procedure called “Calculate” plus the field name. For example, a function called
CalculateNewLimitis required in the data logic procedure to calculate the value for a calculated field calledNewLimit. The function does not have access to the RowObject buffer and needs to make appropriate calls to the SDO to access the buffer if it requires information from the buffer for the calculation. A function to calculate theNewLimitin the data logic procedure might look like the following example:
Dynamic Viewer calculated fields
You can add calculated fields from static or dynamic SDOs as instances onto dynamic viewers. When you create a dynamic viewer with a static SDO as its data source, a
calculatedFieldmaster object might not exist for calculated fields of that SDO. When this occurs, the framework creates mastercalculatedFieldobjects for the calculated fields and sets their product modules to that of the dynamic viewer.Saving static SDOs with calculated fields as dynamic SDOs
When you save a static SDO that contains calculated fields as a dynamic SDO, the framework creates master
calculatedFieldobjects for your calculated fields and saves them in the dynamic SDO. The names of these calculated fields must be unique within the Repository. To complete the change over to a dynamic SDO, you must move the expressions for the calculated fields to calculation functions in the dynamic SDO’s data logic procedure and edit the code as necessary.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |